﻿using DalatCooking.Core;
using DalatCooking.Core.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_BlogDetail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        News n = NewsManager.FindById(NewsId);
        Page.Title = (n != null) ? n.Name : "Not found";
        lblTitle.Text = (n != null) ? n.Name + " #" + n.NewsId : "Not found";
        lblBody.Text = (n != null) ? n.Body : "Not found";
        Category c = CategoryManager.FindById(n.CategoryId);

        lblCategoryName.Text = (c != null) ? c.Name : "Not found";
        pictureCate.Src = "" + ((c != null) ? c.Picture : "/uploads/images/noimage.png");
        lblDesc.Text = (c != null) ? c.Description : "Not found";

        rptOrther.DataSource = NewsManager.FindAll().FindAll(t => t.CategoryId == n.CategoryId);
        rptOrther.DataBind();

    }
    public int NewsId
    {
        get
        {
            if (Request.QueryString["NewsID"] != null)
                return ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString["NewsID"]));
            return -1;
        }
    }
}